package com.study.manage.dal;

import java.util.Date;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;

import com.study.manage.domain.Notification;



public interface NotificationRepository extends PagingAndSortingRepository<Notification, Long> {

    @Query("select t from Notification t where (t.msg like %:name% or :name is null) and (t.userId=:userId or :userId is null) "
            + "and (to_days(t.createdAt)=to_days(:date) or :date is null)")
    Page<Notification> findByMsgAndUserId(@Param("name") String name, @Param("userId") Long userId,
            @Param("date") Date date, Pageable pageable);

}
